package com.foreknow.springboot.controller;

import com.foreknow.springboot.po.Business;
import com.foreknow.springboot.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@SuppressWarnings({"all"})

/**
 * @author xiaoming
 * @version jdk1.8
 * @date 2022/8/12 15:34
 * @function:
 */

@RestController
@RequestMapping("/BusinessController")
public class BusinessController {
    @Autowired
    private BusinessService businessService;

    /**
     * 可以使用Business对象来接收前台的请求参数(无需再写request.getParamter())
     * @param business
     * @return
     * @ResponseBody 将查询到的数据以json格式返回前台
     * @RestController 这是Springboot提供好的 注意(相当于@Controller+@ResponseBody)
     * 面试题:  使用Springboot中提供的@RestController注解有什么好处?
     *          简单了  可以使用一个注解代替两个注解
     */

    //http://localhost:8089/elm/BusinessController/listBusinessByOrderTypeId?orderTypeId=1
    @RequestMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessOrderTypeId(Business business) {
        return businessService.listBusinessOrderTypeId(business.getOrderTypeId());
    }
    //http://localhost:8089/elm/BusinessController/getBusinessById?businessId=10001
    @RequestMapping("/getBusinessById")
    public Business getBusinessById(Business business) {
        return businessService.getBusinessById(business.getBusinessId());
    }
}
